From 169e4d99b1a5d84bf13e6dd6bbe4d44e246e675c Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 16 Mar 2011 16:44:25 +0000 Subject: [PATCH] libxl: provide full path to vif hotplug script script This improves compatibility with xm style config files since xend does this (see NetifController.getDeviceDetails() in tools/python/xen/xend/server/netif.py) and tools/hotplug/Linux/vif-setup expects an absolute path to the script. This patch supports both absolute and relative paths in the configuration. Also, if somehow nic->script==NULL, don't add write the entry to xenstore at all (rather than crashing due to the new check for absolute vs relative path). Signed-off-by: Ian Campbell Signed-off-by: Ian Jackson Committed-by: Ian Jackson --- tools/libxl/libxl.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index a8455d8a30..e4704d19d9 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -1234,8 +1234,13 @@ int libxl_device_nic_add(libxl_ctx *ctx, uint32_t domid, libxl_device_nic *nic) flexarray_append(back, "1"); flexarray_append(back, "state"); flexarray_append(back, libxl__sprintf(&gc, "%d", 1)); - flexarray_append(back, "script"); - flexarray_append(back, nic->script); + if (nic->script) { + flexarray_append(back, "script"); + flexarray_append(back, nic->script[0]=='/' ? nic->script + : libxl__sprintf(&gc, "%s/%s", + libxl_xen_script_dir_path(), + nic->script)); + } flexarray_append(back, "mac"); flexarray_append(back, libxl__sprintf(&gc, "%02x:%02x:%02x:%02x:%02x:%02x", nic->mac[0], nic->mac[1], nic->mac[2], -- 2.30.2